Ordering
ORDER BY
#
对结果进行升序排列,后面加上排序关键字
ORDER BY 关键字默认按照升序(ASC)对记录进行排序。如果需要按照降序对记录进行排序,你可以使用 DESC 关键字。
ORDER BY
关键字可用于对结果集按照多个列进行排序。将对多个列使用 ORDER BY
时,请使用逗号分隔列的列表以跟随 ORDER BY
。
ORDER BY
命令按照与列相同的顺序开始排序。它将按列出的第一列排序,然后按第二列排序,依此类推。
Ordering is ascending, unless the keyword DESC
is specified.
Ties are broken by the second attribute on the ORDER BY
list.
The WHERE
statement is optional.
Do not need to add ASC
because it's default.
Striking through GROUP BY
and HAVING
— we do not need them for ordering the results.
Order by position of attribute name in the relation you're ordering or attribute name:
Order twice: